package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Follow;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class FollowVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "客户ID")
    private Integer customerId;

    @ApiModelProperty(value = "跟进名称")
    private String followName;

    @ApiModelProperty(value = "跟进内容")
    private String content;

    @ApiModelProperty(value = "跟进类型：0电话回访，1线下拜访，2线上联系")
    private String type;

    @ApiModelProperty(value = "跟进进度")
    private String progress;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "下次联系时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date nextTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "跟进人ID")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "附件列表")
    private List<OtherFile> otherFileList;

    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Follow convert(FollowVO vo) {
        Follow entity = new Follow();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Follow> convertList(List<FollowVO> list) {
        List<Follow> resultList = new ArrayList<>();
        for (FollowVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
